package com.demo.mystudy.ui.socketclient.clientcmd

import com.demo.mystudy.event.JetinnoFolerEvent
import com.demo.mystudy.socketbean.JetinnoFolderBean
import com.demo.mystudy.socketbean.MessageWrapper
import com.demo.mystudy.ui.socketclient.WebSocketClientManager
import com.jetinno.simple.utils.JsonUtil
import org.greenrobot.eventbus.EventBus

/**
 * Created by zhangyuncai on 2025/4/28.
 * 描述：
 */
object ClientCmdJetinnoFoler : ClientCmdInterface {
    override val cmd: String
        get() = "JetinnoFolder"

    /**
     * 请求Jetinno文件夹列表
     */
    fun send(parentPath: String){
        val bean= JetinnoFolderBean()
        bean.cmd= cmd
        bean.parentPath=parentPath
        WebSocketClientManager.sendMessage(JsonUtil.anyToJson(bean))
    }

    /**
     * 接收Jetinno文件夹列表
     */
    override fun receive(messageWrapper: MessageWrapper) {
        val bean = JsonUtil.jsonToAny<JetinnoFolderBean>(
            messageWrapper.message,
            JetinnoFolderBean::class.java
        )
        val event = JetinnoFolerEvent(bean)
        EventBus.getDefault().post(event)
    }


}